home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 109
/
Vol 109.iso
/
games
/
paper_ma.swf
/
scripts
/
frame_106
/
DoAction.as
Wrap
Text File
|
2008-11-12
|
3KB
|
119 lines
var heroW = 15;
var heroH = 35;
var velY = 0;
var stepS = 8;
var jumpS = 14;
var jumping = true;
this.onEnterFrame = function()
{
if(Key.isDown(37))
{
var _loc3_ = 0;
while(_loc3_ < stepS)
{
_root.hero._x--;
var _loc2_ = 0;
while(_loc2_ <= heroH)
{
if(_root.ground.hitTest(_root.hero._x - heroW,_root.hero._y - _loc2_,true))
{
_loc3_ = stepS;
_loc2_ = heroH + 1;
_root.hero._x = _root.hero._x + 1;
}
_loc2_ = _loc2_ + 1;
}
_loc3_ = _loc3_ + 1;
}
}
else if(Key.isDown(39))
{
_loc3_ = 0;
while(_loc3_ < stepS)
{
_root.hero._x = _root.hero._x + 1;
_loc2_ = 0;
while(_loc2_ <= heroH)
{
if(_root.ground.hitTest(_root.hero._x + heroW,_root.hero._y - _loc2_,true))
{
_loc3_ = stepS;
_loc2_ = heroH + 1;
_root.hero._x--;
}
_loc2_ = _loc2_ + 1;
}
_loc3_ = _loc3_ + 1;
}
}
if(Key.isDown(38) && !jumping)
{
velY = jumpS;
jumping = true;
}
if(jumping)
{
if(velY > 0)
{
_loc2_ = 0;
while(_loc2_ < velY)
{
_root.hero._y--;
_loc3_ = - heroW;
while(_loc3_ <= heroW)
{
if(_root.ground.hitTest(_root.hero._x + _loc3_,_root.hero._y - heroH,true))
{
_loc2_ = velY;
_loc3_ = heroW + 1;
_root.hero._y = _root.hero._y + 1;
velY = 0;
}
_loc3_ = _loc3_ + 1;
}
_loc2_ = _loc2_ + 1;
}
}
else
{
_loc2_ = 0;
while(_loc2_ > velY)
{
_root.hero._y = _root.hero._y + 1;
_loc3_ = - heroW;
while(_loc3_ <= heroW)
{
if(_root.ground.hitTest(_root.hero._x + _loc3_,_root.hero._y,true))
{
_loc2_ = velY;
_loc3_ = heroW + 1;
_root.hero._y--;
velY = 0;
jumping = false;
}
_loc3_ = _loc3_ + 1;
}
_loc2_ = _loc2_ - 1;
}
}
velY--;
}
else if(!jumping)
{
_loc3_ = - heroW;
while(_loc3_ <= heroW)
{
if(_root.ground.hitTest(_root.hero._x,_root.hero._y + 1,true))
{
break;
}
if(_loc3_ == heroW)
{
velY = 0;
jumping = true;
}
_loc3_ = _loc3_ + 1;
}
}
};